package com.aaa.day1107.demo03;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Period;

/**
 * @author ${崔灿}
 * @date 2022/11/07 16:49
 **/

public class Test {
    public static void main(String[] args) {
        LocalDate date = LocalDate.of(2000,11,1);
        LocalDate now = LocalDate.now();
        //比较两个日期的距离
        Period between = Period.between(date, now);
        System.out.println("相差的年："+between.getYears());
        System.out.println("相差的月："+between.getMonths());
        System.out.println("相差的天："+between.getDays());

        LocalTime time = LocalTime.of(8,8,8);
        LocalTime mow1 = LocalTime.now();
        Duration between1 = Duration.between(time, mow1);
        System.out.println(between1.toHours());
        System.out.println(between1.toMinutes());//时间与时间相差的分钟
        System.out.println(between1.getSeconds());//时间与时间之间相差的秒


    }
}
